import {createRouter, createWebHashHistory} from 'vue-router';
import index from '@/views/index';
import usr_admin from "@/views/usr_admin";
import company_admin from "@/views/company_admin";
import rczp_page from "@/views/rczp_page";

const routes = [
    {
        path: '/',
        name: 'index',
        components: {
            index
        },
        meta: {
            title: '主页'
        }
    },
    {
        path: '/usr/admin/:op',
        name: 'usr_admin',
        components: {
            usr_admin
        },
        meta: {
            title: '个人中心'
        }
    },
    {
        path: '/company/admin/:op',
        name: 'company_admin',
        components: {
            company_admin
        },
        meta: {
            title: '企业中心'
        }
    },
    {
        path: '/company/admin/rczp/:op/:job_id?',
        components: {rczp_page},
        meta: {
            title: '人才招聘'
        }
    }
]

const router = createRouter({
    history: createWebHashHistory(process.env.BASE_URL),
    routes
})
router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next();
})
export default router
